//
//  File.m
//  drawacartoon
//
//  Created by Ji Hu on 12-7-24.
//  Copyright (c) 2012年 爱辅导. All rights reserved.
//

#import "File.h"

static NSString *cartoonDirectory ;

@implementation File

+(NSString *)cartoonDirectoryPath{
    
    if (cartoonDirectory==nil) {
        
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        cartoonDirectory = [[NSString stringWithFormat:@"%@/cartoons",documentsDirectory] retain];
        
        NSFileManager *filemanager = [NSFileManager defaultManager];
        
        if (![filemanager fileExistsAtPath:cartoonDirectory]) {
            [filemanager createDirectoryAtPath:cartoonDirectory withIntermediateDirectories:NO attributes:nil error:nil];
        }
    }
    
    return cartoonDirectory;
}

+(NSString *)oneCartoonPath:(NSString *)name{
    
    NSString *ocp = [NSString stringWithFormat:@"%@/%@",[File cartoonDirectoryPath],name];
    
    NSFileManager *filemanager = [NSFileManager defaultManager];
    
    if (![filemanager fileExistsAtPath:ocp]) {
        return ocp;
    }else {
        return nil;
    }
   
}

@end
